/**
 * Copyright (c) 2009 Cerner Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Cerner Corporation - initial API and implementation
 */
package com.cerner.system.rest.jaas.cas;

import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
import javax.security.auth.spi.LoginModule;

import org.restlet.data.Status;

/**
 * Internal failure exception that is useful for the propagation of
 * HTTP-transport errors. Even those these errors qualify as "faults" a checked
 * exception is chosen because {@link LoginContext} swallows unknown exceptions.
 * So error handlers in a {@link LoginModule} should wrap {@code
 * CasConnectorException} as a {@link LoginException}.
 * 
 * @author Alex Horn
 * @since 1.0.0
 */
class CasConnectorFault extends Exception {

  CasConnectorFault(String message) {
    super(message);
  }

  CasConnectorFault(Throwable cause) {
    super(cause);
  }

  CasConnectorFault(Status status) {
    super(
        "CAS send operation failed with HTTP status code: ".concat(status.toString()));
  }

  CasConnectorFault(String username, org.restlet.data.Status status) {
    super("Cannot login user '".concat(username).concat(
        "'. CAS responded with ".concat(status.toString())));
  }

  private static final long serialVersionUID = 0;

}
